<?php
  if (!defined('baseinfo')) {
    exitdata();
}  
?>
<div class="ovlPopGen wrpPopIndexPost" >
        <div class="popGen posPop">
            <div class="topGen clBd2 bdBtm">
                <div class="wrpTtlGen">
                    <h1 class="ttlGen clTxt2 fs05">Post Index</h1>
                </div>
                <div class="btnIco closeGen" onclick="$('.wrpPopIndexPost').fadeOut()">
                    <span class="ico icoCloseGen"></span>
                </div>
                <div class="topBgGen clBg3"></div>
            </div>
            <div class="bodyGen clBg3">
                <div class="bodyOutGen">
                    <div class="bodyInGen">
                        <p class="desAddGen clTxt3 fs03">Select a feature menu to point this post.</p>
                        <form class="wrpFrmGen" id="featuregen">
                            <fieldset class="wrpFrmCbInx">
                            <?if(count($data['feature']))
                            {
                                 foreach($data['feature'] as $valuefeature)
                                 {?>
                                <div class="wrpInFrmCbInx">
                                    <input class="classfeature" name="featureset[]" value="<?=$valuefeature['fid']?>" id="fpostid-<?=$valuefeature['fid']?>" type="checkbox">
                                    <label for="" class="clTxt3 fs03"><?=$valuefeature['name']?></label>
                                </div>
                                <?}
                                
                            }?>
                              <!--  <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 2</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 3</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 4</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 5</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 6</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 7</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 8</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 9</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 10</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 11</label>
                                </div>
                                <div class="wrpInFrmCbInx">
                                    <input type="checkbox">
                                    <label for="" class="clTxt3 fs03">Feature 12</label>
                                </div>-->
                            </fieldset>
                            <div class="wrpBtnGen">
                                <input type="button" onclick="savefeaturepoint()" value="OK" class="btnGen clTxtW btnSend cutTxt clBgSp2 fs04">
                                <input type="button" onclick="$('.wrpPopIndexPost').fadeOut()" value="Cancel" class="btnGen clTxtW btnCncl cutTxt clBgBt1 fs04">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script>
var productidset=0;
var orderbyset='';
function savefeaturepoint()
{

$.post(serviceinfo+'savefeaturepoint', $('input[name="featureset[]"]').serialize()+'&productid='+productidset, function(data) {
boxmsgdata('Success');
$('.wrpPopIndexPost').fadeOut();
});

}
function savepostdata()
{

$.post(serviceinfo+'saveuserscreen', $('#saveproductdata').serialize(), function(data) {
boxmsgdata('Success');
//changefeaturedata(1,fidset);
});

}
function getpostdata(productid)
{
productidset=productid;
$('.wrpPopIndexPost').fadeIn();
$('.classfeature').prop('checked', false);
$.get(serviceinfo+'getfeaturepoint', {productid:productid}, function(data) {
if(data.data.length>0)
 {
 $.each(data['data'], function(key, value) {
 //console.log('#fpostid-'+value['fid']);
 
 $('#fpostid-'+value['fid']).prop('checked', true);
 
 
 });
 
 }


});
}
var pagedata=1;
var pagedata2=1;
var fidset=0;
function changefeaturedata(pagedataset,fid,param2,param3)
{
fidset=fid;
var sticky="";
if(pagedataset==1)
{
pagedata=pagedataset;

}
orderbyset='';
if(param2!='undefined')
{
orderbyset=param2;
}

$('.wrpInPassZone').html('');

//console.log(pagedataset);

$.get(serviceinfo+'getproduct', {fid:fid,page:pagedata,search:$('#searchboxdata').val(),orderby:orderbyset,nocache:1}, function(data) {
  
 pagedata++;  
 if(data.data.length>0)
 {
       $.each(data['data'], function(key, value) {
       
       
var code = '<div class="cellScn" id="wrpInCell-'+value.productid+'" >\n';
code += '<div class="wrpOrdMdMn clBg5 clTxt2 center">\n';
code += '<span class="txtOrdMn fs03">order</span>\n';
code += '<div class="inpNoFtMn center">\n';
code += '<input type="text" value="'+value.position+'" name="position[]" class="clBg5 clBd2 bdBtm fs02" kl_virtual_keyboard_secure_input="on">\n';
code +=' <input type="hidden" value="'+value.productid+'" name="productid[]" class="clBg5 clBd2 bdBtm fs02" kl_virtual_keyboard_secure_input="on">';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInCellScn clBd2 bdFull clBg3">\n';
code += '<div class="wrpBtnScnCell clearfix">\n';
code += '<div class="btnMnCell clBgBt1" onclick="deleteproduct('+value.productid+')">\n';
code += '<span class="ico icoDelCell"></span>\n';
code += '</div>\n';
code +='<div class="btnMnCell indxCell clBgBt1" onclick="getpostdata('+value.productid+','+value.fid+')">\n';
code += '<span class="ico icoInfoCell"></span>\n';
code += '</div>\n';
sticky="";
if(value.position!="0")
{
sticky="clPassCell";
}


code += '<div class="btnMnCell stkCell clBgBt1 '+sticky+'" onclick="savestickypost('+value.productid+')">';
code += '<span class="clTxtW fs00">Sticky</span>';
code += '</div>';

code += '<div class="btnMnCell btnScnCell clBgBt1 clPassCell" onclick="actiondeletedata(0,'+value.productid+')">\n';
code += '<span class="ico icoScnCell"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="scnCell clearfix">\n';
code += '<div class="imgScnCell" onclick="linkto(\''+baseinfo+'/post/'+value.productid+'\')">\n';
code += '<img width="100" height="100" alt="img" src="'+value.simg.newpath+'">\n';
code += '</div>\n';
code += '<div class="dtScnCell fs03" onclick="linkto(\''+baseinfo+'/post/'+value.productid+'\')">\n';
code += '<div class="authDateScnCell clTxt3 fs02">\n';
code += '<div class="authScnCell">\n';
code += '<span>By</span>\n';
code += '<span>'+value.displayname+'</span>\n';
//code += '<span class="proUser clTxtW clBgSp2 fs01">Pro</span>\n';
code += '</div>\n';
code += '<div class="dateScnCell">\n';
code += '<span>'+value.newdate+'</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ttlScnCell">\n';
code += '<h2 class="fs04">'+value.title+'</h2>\n';
code += '<p class="clTxt3">'+value.description+'</p>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

$('.wrpInPassZone').append(code);



       
       
       });
       
     //  setpagination(div,'#pageAllwrpInPassZone',rowpage,func,param1,param2,param3)
     if(pagedataset==1)
     {
      //  console.log(1);
       setpagination('#pageAllwrpInPassZone',data['page'],1,'changefeaturedata',fid,param2,'');
     }
 }
  
  
  
  });
  
  

  

}

function changefeaturefilterdata(pagedataset,fid,param2,param3)
{
fidset=fid;
if(pagedataset==1)
{
pagedata2=pagedataset;

}
orderbyset='';
if(param2!='undefined')
{
orderbyset=param2;
}


$('.wrpInFilterZone').html('');
//console.log(pagedataset);

  
  
 $.get(serviceinfo+'getproduct', {fid:fid,page:pagedata,search:$('#searchboxdata').val(),orderby:orderbyset,deletezone:1,nocache:1}, function(data) {
  
 pagedata2++;  
 if(data.data.length>0)
 {
       $.each(data['data'], function(key, value) {
       
       
var code = '<div class="cellScn" id="wrpInCell-'+value.productid+'" >\n';
code += '<div class="wrpOrdMdMn clBg5 clTxt2 center">\n';
code += '<span class="txtOrdMn fs03">order</span>\n';
code += '<div class="inpNoFtMn center">\n';
code += '<input type="text" value="'+value.position+'" name="position[]" class="clBg5 clBd2 bdBtm fs02" kl_virtual_keyboard_secure_input="on">\n';
code +=' <input type="hidden" value="'+value.productid+'" name="productid[]" class="clBg5 clBd2 bdBtm fs02" kl_virtual_keyboard_secure_input="on">';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInCellScn clBd2 bdFull clBg3">\n';
code += '<div class="wrpBtnScnCell clearfix">\n';
//code += '<div class="btnMnCell clBgBt1" onclick="deleteproduct('+value.productid+')">\n';
//code += '<span class="ico icoDelCell"></span>\n';
//code += '</div>\n';
//code += '<div class="btnMnCell indxCell clBgBt1" onclick="getpostdata('+value.productid+','+value.fid+')">\n';
//code += '<span class="ico icoInfoCell"></span>\n';
//code += '</div>\n';
code += '<div class="btnMnCell btnScnCell clBgBt1" onclick="actiondeletedata(1,'+value.productid+')">\n';
code += '<span class="ico icoScnCell"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="scnCell clearfix">\n';
code += '<div class="imgScnCell" onclick="linkto(\''+baseinfo+'/post/'+value.productid+'\')">\n';
code += '<img width="100" height="100" alt="img" src="'+value.simg.newpath+'">\n';
code += '</div>\n';
code += '<div class="dtScnCell fs03" onclick="linkto(\''+baseinfo+'/post/'+value.productid+'\')" >\n';
code += '<div class="authDateScnCell clTxt3 fs02">\n';
code += '<div class="authScnCell">\n';
code += '<span>By</span>\n';
code += '<span>'+value.displayname+'</span>\n';
//code += '<span class="proUser clTxtW clBgSp2 fs01">Pro</span>\n';
code += '</div>\n';
code += '<div class="dateScnCell">\n';
code += '<span>'+value.newdate+'</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="ttlScnCell">\n';
code += '<h2 class="fs04">'+value.title+'</h2>\n';
code += '<p class="clTxt3">'+value.description+'</p>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

$('.wrpInFilterZone').append(code);



       
       
       });
       
     //  setpagination(div,'#pageAllwrpInPassZone',rowpage,func,param1,param2,param3)
     if(pagedataset==1)
     {
      //  console.log(1);
       setpagination('#pageAllwrpInFilterZone',data['page'],1,'changefeaturefilterdata',fid,param2,'');
     }
 }
  
  
  
  });
  

}

function actiondeletedata(undelete,productid)
{
 $.post(serviceinfo+'deleteproduct', {undelete:undelete,productid:productid}, function(data) {
 changefeaturedata(1,0);
changefeaturefilterdata(1,0);
 });
}

function savestickypost(productid)
{
 $.post(serviceinfo+'savestickypost', {productid:productid}, function(data) {
 
 changefeaturedata(1,0);
 });

}

changefeaturedata(1,0);
changefeaturefilterdata(1,0);
</script>